<?php

/** 页面显示路由 */
Route::group(["middleware"=>["web"]],function(){
    Route::get('newGoodsDetail',['as' => 'Home.Page.newGoodsDetail', 'uses' => 'HomeController@newGoodsDetail']);
    Route::get('showGoods',['as' => 'Home.Page.showGoods', 'uses' => 'HomeController@showGoods']);

    Route::group(['prefix'=>'home'],function(){
        Route::get('login',['as' => 'Home.Auth.login', 'uses' => 'HomeController@login']);
        Route::get('register',['as' => 'Home.Auth.register', 'uses' => 'HomeController@register']);
        Route::get('forget-password',['as' => 'Home.Auth.forgetPassword', 'uses' => 'HomeController@forgetPassword']);
        Route::get('change-password',['as' => 'Home.Auth.changePassword', 'uses' => 'HomeController@changePassword']);

        Route::get('baibaoxiang',['as' => 'Home.User.baibaoxiang', 'uses' => 'HomeController@baibaoxiang']);
        Route::get('userinfo',['as' => 'Home.User.userinfo', 'uses' => 'HomeController@userinfo']);
        Route::get('myexchange',['as' => 'Home.User.myexchange', 'uses' => 'HomeController@myexchange']);
        Route::get('change-info',['as' => 'Home.User.changeInfo', 'uses' => 'HomeController@changeInfo']);
        Route::get('my-address',['as' => 'Home.User.myAddress', 'uses' => 'HomeController@myAddress']);
        Route::get('my-new-address',['as' => 'Home.User.myNewAddress', 'uses' => 'HomeController@myNewAddress']);
        Route::get('change-address',['as' => 'Home.User.changeAddress', 'uses' => 'HomeController@changeAddress']);
        Route::get('my-share',['as' => 'Home.User.myShare', 'uses' => 'HomeController@myShare']);
        Route::get('qian-dao',['as' => 'Home.User.qiandao', 'uses' => 'HomeController@qiandao']);
        Route::get('coin-detail',['as' => 'Home.User.coinDetail', 'uses' => 'HomeController@coinDetail']);

        Route::get('goods-list',['as'   => 'Home.Goods.goodsList', 'uses' => 'HomeController@goodsList']);
        Route::get('goods-list-cash',['as'   => 'Home.Goods.goodsListCash', 'uses' => 'HomeController@goodsListCash']);
        Route::get('goods-detail',['as' => 'Home.Goods.goodsDetail', 'uses' => 'HomeController@goodsDetail']);
        Route::get('goods-detail-cash',['as' => 'Home.Goods.goodsDetailCash', 'uses' => 'HomeController@goodsDetailCash']);
        Route::get('goods-buy',['as' => 'Home.Goods.goodsBuy', 'uses' => 'HomeController@goodsBuy']);
        Route::get('goods-buy-cash',['as' => 'Home.Goods.goodsBuyCash', 'uses' => 'HomeController@goodsBuyCash']);
        Route::get('confirm-order',['as' => 'Home.Goods.confirmOrder', 'uses' => 'HomeController@confirmOrder']);
        Route::get('confirm-order-cash',['as' => 'Home.Goods.confirmOrderCash', 'uses' => 'HomeController@confirmOrderCash']);

        Route::get('youlai',['as' => 'Home.Page.youlai', 'uses' => 'HomeController@youlai']);
        Route::get('dingzhi',['as' => 'Home.Page.dingzhi', 'uses' => 'HomeController@dingzhi']);
        Route::get('hujiao',['as' => 'Home.Page.hujiao', 'uses' => 'HomeController@hujiao']);

        Route::get('newOrder',['as' => 'Home.Page.newOrder', 'uses' => 'HomeController@newOrder']);

    });

    Route::group(['prefix'=>'pc'],function(){
        Route::get('index',['as' => 'Home.Pc.pcIndex', 'uses' => 'HomeController@pcIndex']);
    });

    Route::group(['prefix'=>'admin'],function(){
        Route::get('/',['as' => 'Admin.Page.login', 'uses' => 'AdminController@login']);
        Route::get('user-list',['as' => 'Admin.Page.userList', 'uses' => 'AdminController@userList']);
        Route::get('goods-list',['as' => 'Admin.Page.goodsList', 'uses' => 'AdminController@goodsList']);
        Route::get('order-list',['as' => 'Admin.Page.orderList', 'uses' => 'AdminController@orderList']);
        Route::get('add-goods',['as' => 'Admin.Page.addGoods', 'uses' => 'AdminController@addGoods']);
        Route::get('banner-list',['as'=>'Admin.Sys.bannerList','uses'=>'AdminController@bannerList']);
        Route::get('banner-set',['as'=>'Admin.Sys.bannerSet','uses'=>'AdminController@bannerSet']);
        Route::get('login-out',['as'=>'Admin.Page.loginOut','uses'=>'AdminController@loginOut']);
    });
});

/** 接口路由 */
Route::group(['middleware' => ['web']], function () {
    Route::group(['prefix'=>'api', 'namespace'=>'Api'],function(){
        /** 验证相关接口 */
        Route::group(['prefix' => 'auth'],function(){
            /** 通过手机获取短信验证码接口 */
            Route::post('get-phone-code', ['as' => 'Api.Auth.getVerifyCodeByPhone', 'uses' => 'AuthController@getVerifyCodeByPhone']);
            Route::post('sign-up', ['as' => 'Api.Auth.signUp', 'uses' => 'AuthController@signUp']);
            Route::post('sign-in', ['as' => 'Api.Auth.signIn', 'uses' => 'AuthController@signIn']);
            Route::post('reset-password', ['as' => 'Api.Auth.ResetPassword', 'uses' => 'AuthController@ResetPassword']);
            Route::get('login-out', ['as' => 'Api.Auth.loginOut', 'uses' => 'AuthController@loginOut']);
            Route::any('wechatCallback', ['as' => 'Api.Auth.wechatCallback', 'uses' => 'AuthController@wechatCallback']);
            Route::get('wechatLogin', ['as' => 'Api.Auth.wechatLogin', 'uses' => 'AuthController@wechatLogin']);
            Route::any('updateCode', ['as' => 'Api.Auth.updateCode', 'uses' => 'AuthController@updateCode']);
        });

        /** 图片上传和显示接口 2017.12.19 */
        Route::group(['prefix' => 'file'],function(){
            /** 输出原图片接口 2017.12.19 */
            Route::get('photo-show/{id}',['as'=>'Api.Image.showPhotoByUserid','uses'=>'ImageController@showPhotoByUserid']);
            Route::get('image-show/{id}',['as'=>'Api.Image.Show','uses'=>'ImageController@getImageUrlById']);
            /** 输出不同尺寸图片接口 2017.12.19 */
            Route::get('image-show/{id}/size/{px}',['as'=>'Api.Image.ShowPX','uses'=>'ImageController@getImageBinAsShowById']);
            /** 剪裁图片接口 2017.12.19 */
            Route::post('crop-image',['as'=>'Api.Image.CropImage','uses'=>'ImageController@CropImage']);
            /** 上传图片接口 2017.12.19 */
            Route::post('upload-image',['as'=>'Api.Upload.Image','uses'=>'ImageController@upload']);
        });


        Route::group(['prefix' => 'wechat'],function(){
            Route::any('index',['as'=>'Api.Wechat.index','uses'=>'WechatController@index']);
            Route::post('get-js-api-packet',['as'=>'Api.Wechat.getJsApiPacket','uses'=>'WechatController@getJsApiPacket']);
            Route::any('callback',['as'=>'Api.Wechat.wechatCallback','uses'=>'AuthController@wechatCallback']);
        });

        Route::group(['prefix' => 'user'],function(){
            Route::post('set-address',['as'=>'Api.User.setUserAddress','uses'=>'UserController@setUserAddress']);
            Route::post('del-address',['as'=>'Api.User.delUserAddress','uses'=>'UserController@delUserAddress']);
            Route::get('qian-dao',['as'=>'Api.User.qianDao','uses'=>'UserController@qianDao']);
            Route::get('get-my-signeds',['as'=>'Api.User.getMySigneds','uses'=>'UserController@getMySigneds']);
            Route::post('set-userinfo',['as'=>'Api.User.setUserInfo','uses'=>'UserController@setUserInfo']);
            Route::post('change-password',['as'=>'Api.User.changePassword','uses'=>'UserController@changePassword']);
        });

        Route::group(['prefix' => 'good'],function(){
            Route::post('build-order',['as'=>'Api.Good.buildOrder','uses'=>'GoodsController@buildOrder']);
            Route::post('confirm-order',['as'=>'Api.Good.confirmOrder','uses'=>'GoodsController@confirmOrder']);
        });

        Route::group(['prefix' => 'pay'],function(){
            Route::post('pay-jsapi',['as'=>'Api.Payment.payByWechatJsApi','uses'=>'PaymentController@payByWechatJsApi']);
            Route::any('wechatPayCallBack',['as'=>'Api.Payment.wechatPayCallBack','uses'=>'PaymentController@wechatPayCallBack']);
        });

        Route::group(['prefix' => 'admin'],function(){
            Route::post('sign-in', ['as' => 'Api.Admin.Auth.signInAdmin', 'uses' => 'Admin\AuthController@signInAdmin']);
            Route::post('add-goods', ['as' => 'Api.Admin.Good.addGoods', 'uses' => 'Admin\GoodsController@addGoods']);
            Route::post('set-banner',['as'=>'Api.Admin.Good.setBanner','uses'=>'Admin\GoodsController@setBanner']);
            Route::post('del-banner',['as'=>'Api.Admin.Good.delBanner','uses'=>'Admin\GoodsController@delBanner']);
            Route::post('set-banner-status',['as'=>'Api.Admin.Good.setBannerStatus','uses'=>'Admin\GoodsController@setBannerStatus']);
        });
    });
});
